<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box">
        <a href="#qwer">首页</a>
        <a href="#asdf">第二页</a>
        <a href="#zxcv">第三页</a>
    </div>
    <div class="conment"></div>
</body>

</html>
<script>
    window.onhashchange = () => {
        if (location.hash == '#qwer') {
            shouye()
        } else if (location.hash == '#asdf') {
            dierye()
        } else if (location.hash == '#zxcv') {
            disanye()
        }
    }
    function shouye() {
        document.querySelector('.conment').innerHTML = '渲染首页的内容<img src="img/1.png" alt="">'
    }
    function dierye() {
        document.querySelector('.conment').innerHTML = '渲染第二页的内容<img src="img/2.png" alt="">'
    }
    function disanye() {
        document.querySelector('.conment').innerHTML = '渲染第三页的内容<img src="img/3.png" alt="">'
    }
</script>